<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Session;

class AdminController extends Controller
{
    //
    public function _initialize()
    {
        parent::_initialize();
        if (!session::has('admin_user')) {
            $this->redirect("admin/LoginController/index");
        }


        // 权限过滤

        //获取控制器和方法名

        $mname = Request::instance()->controller();
        $aname = Request::instance()->action();
        $nodelist = session::get('admin_node');
        
        if (session::get('admin_user') != 'admin') {
            if(empty($nodelist[$mname]) || !in_array($aname,$nodelist[$mname])){
                $this->error('抱歉！您暂时还没有操作权限～');
                exit;
            }
        }


    }

}
